package com.example.blog.service;

import com.example.blog.dao.ArticleRepository;
import com.example.blog.po.Article;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BlogService {

    @Autowired
    private ArticleRepository articleRepository;

    public Page<Article> pageArticle(Integer pageNum){
        Pageable pageable = PageRequest.of(pageNum,1);
        Page<Article> page = articleRepository.findAll(pageable);
//        List<Article> all = articleRepository.findAll();
        return page;
    }
}
